package rtda

import "gvm/rtda/heap"

type JFrame struct {
	lower        *JFrame
	localVars    *LocalVars
	operandStack *OperandStack // 堆栈
	jThread      *JThread
	method       *heap.Method
	nextPc       int // 下一个被执行的指令
}

func newJFrame(thread *JThread, method *heap.Method) *JFrame {
	return &JFrame{
		jThread:      thread,
		method:       method,
		localVars:    NewLocalVars(method.MaxLocals()),
		operandStack: newOperandStack(method.MaxStack()),
	}
}

func (self *JFrame) OperandStack() *OperandStack {
	return self.operandStack
}

func (self *JFrame) LocalVars() *LocalVars {
	return self.localVars
}

func (self *JFrame) JThread() *JThread {
	return self.jThread
}
func (self *JFrame) Method() *heap.Method {
	return self.method
}

func (self *JFrame) NextPC() int {
	return self.nextPc
}

func (self *JFrame) SetNextPC(nextPC int) {
	self.nextPc = nextPC
}

func (self *JFrame) RevertNextPC() {
	self.nextPc = self.jThread.pc
}
